package com.es.core.utils;

import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * spring 工具类
 */
public class BeanUtil {
    private static AbstractApplicationContext app;

    static {
        app = new ClassPathXmlApplicationContext(new String[]{"applicationContext.xml"});
    }

    /**
     * @param beanName
     * @param cla
     * @param <T>
     * @return
     */
    public static <T> T getBean(String beanName, Class<T> cla) {
        T t = app.getBean(beanName, cla);
        return t;
    }
}
